﻿/********************************************************
 * 类名： CustomerCategoryBLL.cs
 * 功能： 客户类别业务层
 *   ver	变更日		作者			变更内容
 * ────────────────────────────────────────
 *   V01.0	2013-11-27	李波			初版
 *
 * Copyright (c) 2013，李波版权所有
 ********************************************************/
using System;
using System.Collections;
using PSS.DAL.SetManage.AuxiliaryInfo;
using PSS.Entity;
using PSS.Entity.SetManage.AuxiliaryInfo;
using PSS.Utility;

namespace PSS.BLL.SetManage.AuxiliaryInfo
{
    public class CustomerCategoryBLL
    {
        private readonly CustomerCategoryDAL _dal = new CustomerCategoryDAL();
        public string GetCustomerCategoryList(Pagination qcmodel)
        {
            var total = _dal.GetTotal();
            var list = _dal.GetCustomerCategoryList(qcmodel);
            return JsonHelper.Encode(total, list);
        }
        public string GetCustomerCategoryListByCombobox()
        {
            return JsonHelper.Encode(_dal.GetCustomerCategoryListByCombobox());
        }
        public bool ModifyCustomerCategory(string data)
        {
            var model = new CustomerCategoryEntity();
            var rows = (ArrayList)JsonHelper.Decode(data);
            foreach (Hashtable row in rows)
            {
                model.CCategoryId = new Guid(row["CCategoryId"].ToString());
                model.CCategoryName = row["CCategoryName"].ToString();
            }
            return _dal.ModifyCustomerCategory(model);
        }
        public bool AddCustomerCategory(string data)
        {
            var model = new CustomerCategoryEntity();
            var rows = (ArrayList)JsonHelper.Decode(data);
            foreach (Hashtable row in rows)
            {
                model.CCategoryId = Guid.NewGuid();
                model.CCategoryName = row["CCategoryName"].ToString();
            }
            return _dal.AddCustomerCategory(model);
        }
        public string GetCustomerCategoryInfo(string id)
        {
            return JsonHelper.Encode(_dal.GetCustomerCategoryInfo(id));
        }
        public bool RemoveCustomerCategory(string id)
        {
            return _dal.RemoveCustomerCategory(id);
        }
    }
}
